package sctu.edu.java.year2016.team05.zengkun.day20160601.listtest;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by mike on 2016/6/1.
 */
public class CollectionDemo {
    public static void main(String[] args) {
        String a = "A", b = "B", c = "C", d = "D", e = "E";
        List<String> list = new LinkedList<String>();
        list.add(a);
        list.add(e);
        list.add(d);
        Iterator<String> firstlterator = list.iterator();
        System.out.println("修改前集合中的元素是：");
        while (firstlterator.hasNext()) {
            System.out.println(firstlterator.next() + " ");
        }
        list.set(1, b);
        list.add(2, c);
        Iterator<String> it = list.iterator();
        System.out.println();
        System.out.println("修改集合中的元素是：");
        while (it.hasNext()) {
            System.out.println(it.next() + " ");
        }
    }
}
